using Maki;
using System;

public static class MakiEX
{
    public static void visitAction<T1, T2>(this Variant<T1, T2> self, Action<T1> m1, Action<T2> m2)
    {

        switch (self.Get())
        {
            case T1 t1:
                m1?.Invoke(self.Get<T1>());
                break;
            case T2 t2:
                m2?.Invoke(self.Get<T2>());
                break;
        }
    }
    public static T3 visitFunc<T1, T2, T3>(this Variant<T1, T2> self, Func<T1, T3> m1, Func<T2, T3> m2) 
    {
        switch (self.Get())
        {
            case T1 t1:
                if (m1 == null) return default(T3);
                return m1.Invoke(self.Get<T1>());
            case T2 t2:
                if (m2 == null) return default(T3);
                return m2.Invoke(self.Get<T2>());
        }
        return default(T3);
    }
}